<!doctype html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>有奖答题平台</title>
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
    <link rel="stylesheet" href="/lib/mobile/css/common.css"/>
    <link rel="stylesheet" href="/lib/mobile/css/answer.css"/>
    <link rel="stylesheet" href="/mobile/css/bui.css" />
</head>
<body>

<div class="answer_finish">
    <div class="finish_header">
        <img src="/lib/mobile/img/answer_finish_bg.png" alt="">
        <strong><span id="right"></span></strong>
    </div>
    <div class="finish_body">
        <ul class="finish_list">
            <li>正确率: <span id="rate"></span>%</li> <!-- 100%显示弹窗 -->
            <li>用时: <span id="usetime"></span></li>
            <li>错题数:<span id="error"></span></li>
            <li>积分: +<span id="point"></span></li>
        </ul>
        <div class="finish_button">
            <dl class="finish_1" id="analysis"><a href="javascript:void(0)">答案解析</a></dl>
            <dl class="finish_2 on" id="answer"><a href="javascript:void(0)">再来一次</a></dl>
        </div>
    </div>
</div>
<!--class="pop"-->
<div class="pop">
    <div class="prize" id="prize"><a href="javascript:void(0)"><img src="/lib/mobile/img/prize.jpg" alt=""/></a></div>
</div>
<ul class="bottom_menu">
    <li  id="indexsy"><a href="javascript:void(0);">首页</a></li>
    <!--<li>|</li>-->
    <li  id="hdrule"><a href="javascript:void(0);">活动规则</a></li>
    <!--<li  id="point_rule"><a href="javascript:void(0);">积分规则</a></li>-->
    <!--<li>|</li>-->
    <!--<li id="prize_rule"><a href="javascript:void(0);">抽奖规则</a></li>-->
    <!--<li>|</li>-->
    <li id="center"><a href="javascript:void(0);">个人中心</a></li>
</ul>
</body>
<script src="/lib/mobile/js/zepto.js"></script>
<script src="/lib/mobile/js/plugins/fastclick.js"></script>
<script src="/lib/mobile/js/bui.js"></script>
<script src="/lib/mobile/js/common.js?00    "></script>
<script>
    var dtcn=0;
   bui.ready(function () {
       // 这里写业务及控件初始化
       var storage = bui.storage();
       bui.btn({id: ".bui-page", handle: ".bui-btn"}).load();
       var pageview = {};
       pageview.init = function () {
           var uid=storage.get("uid");
           // 验证码示例
           $("#indexsy").on("click", function (argument) {
               bui.load({ url: BASE_URL+"mobile/index"});
           });
           $("#point_rule").on("click", function (argument) {
               bui.load({ url: BASE_URL+"mobile/point_rule"});
           });
           $("#prize_rule").on("click", function (argument) {
               bui.load({ url: BASE_URL+"mobile/prize_rule"});
           });
           $("#center").on("click", function (argument) {
               bui.load({ url: BASE_URL+"mobile/center"});
           });
           $("#analysis").on("click", function (argument) {
               bui.load({ url: BASE_URL+"mobile/analysis"});
           });
           $("#answer").on("click", function (argument) {
               getMyPointList(uid[0],'');
           });
           $("#prize").on("click", function (argument) {
               bui.load({ url: BASE_URL+"mobile/prize"});
           });
           var dtid=storage.get("dtid");


           getFinishList(uid[0],dtid[0]);
       }
       pageview.init();
   });
   function getFinishList(uid,dtid) {
       //执行登录操作
       var loginAjax = bui.ajax({
           url: BASE_URL+"mobile/getFinishList",
           // 可选参数
           data: {
               uid:uid,
               dtid:dtid
           },
           method: "POST"
       });
       loginAjax.then(function(res) {
           var data = res.data;
           // console.log(data);
           $("#rate").html(data.rate);
           $("#usetime").html(data.usetime);
           $("#error").html(data.error);
           $("#right").html(data.right);
           $("#point").html(data.point);
           // $("#score").val(data.score);
               if (data.rate==100) {
                   setTimeout(() => {
                       $('.pop').fadeIn(400)
               }, 1500)
               }
       },function(res) {
           bui.alert("请求异常");
       })
   }
    function getMyPointList(uid,rq) {
        //执行登录操作
        var loginAjax = bui.ajax({
            url: BASE_URL+"mobile/getMyPointList",
            // 可选参数
            data: {
                uid:uid,
                rq:rq
            },
            method: "POST"
        });
        loginAjax.then(function(res) {
            if(res.code == 0){
                var user = res.data;
                dtcn=user.dtcn;
                // dtcn=100;
                if(dtcn<=5){
                    bui.confirm({
                        content: "每月限答题5次，点击确定进入答题窗口！",
                        title: "开始答题",
                        buttons: ["取消", "确定"],
                        callback: function (e) {
                            var text = $(e.target).text();
                            if( text == "确定") {
                                bui.load({url: BASE_URL + "mobile/answer"});
                            }else{
                                bui.alert("已取消答题！");
                            }
                        }
                    });
                }else if(dtcn>5){
                    bui.alert("今日答题"+dtcn+"次，请明天再来！");
                }
            }else{
                bui.alert(res.msg);
            }
        },function(res) {
            bui.alert("请求异常");
        })
    }
</script>

</html>